
Ext.define('ZO0.view.shipping.UPSZone', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.upszone',

    title: 'Zones',
    store: 'shipping.UPSZone',

    frame: true,
    columnLines: true,
    selType: 'cellmodel',

    initComponent: function() {
        var me = this;

        me.afterEdit = function() {
            var cell = me.getView().getSelectionModel().getSelection()[0];
            cell.commit();
	};
        me.editing = Ext.create('Ext.grid.plugin.CellEditing');
	me.editing.addListener('afteredit', me.afterEdit);


        Ext.applyIf(me, {
            height: 400,
            plugins: [me.editing],
            viewConfig: { stripeRows: true },
            columns: [
                { xtype: 'gridcolumn', header: 'From:', dataIndex: 'zip_from', width: 70, align: 'center', locked: true },
                { xtype: 'gridcolumn', header: 'To:', dataIndex: 'zip_to', width: 70, align: 'center', locked: true },
                { xtype: 'gridcolumn', header: 'Ground', dataIndex: 'ground', width: 70, align: 'center', sortable: false, menuDisabled: true, tooltip: 'Ground',
                    editor: { xtype: 'textfield', allowBlank: false }
                },
                { xtype: 'gridcolumn', header: '3 Day', dataIndex: '_3day', width: 70, align: 'center', sortable: false, menuDisabled: true, tooltip: '3 Days',
                    editor: { xtype: 'textfield', allowBlank: false }
                },
                { xtype: 'gridcolumn', header: '2 Day', dataIndex: '_2day', width: 70, align: 'center', sortable: false, menuDisabled: true,
                    editor: { xtype: 'textfield', allowBlank: false }
                },
                { xtype: 'gridcolumn', header: '2 Day AM', dataIndex: '_2day_am', width: 70, align: 'center', sortable: false, menuDisabled: true,
                    editor: { xtype: 'textfield', allowBlank: false }
                },
                { xtype: 'gridcolumn', header: '1 Day Saver', dataIndex: '_1day_saver', width: 70, align: 'center', sortable: false, menuDisabled: true,
                    editor: { xtype: 'textfield', allowBlank: false }
                },
                { xtype: 'gridcolumn', header: '1 Day', dataIndex: '_1day', width: 70, align: 'center', sortable: false, menuDisabled: true,
                    editor: { xtype: 'textfield', allowBlank: false }
                },
                { xtype: 'gridcolumn', header: '1 Day AM', dataIndex: '_1day_am', width: 70, align: 'center', sortable: false, menuDisabled: true,
                    editor: { xtype: 'textfield', allowBlank: false }
                }
            ],
            dockedItems: [{
                xtype: 'pagingtoolbar',
                store: 'shipping.UPSZone',
                dock: 'bottom',
                width: 360,
                displayInfo: true
            }],
            listeners: {
                render: function(grid) {
                    grid.getStore().load();
                }
            }
        });
        me.callParent(arguments);
    }
});
